{extend name="base"/}
{block name="main"}
<style>
    .table>tbody>tr>td{
        text-align: center;
    }
</style>
<div class="Hui-article">
    <article class="cl pd-20">
        <div class="n_tab_line">
            <a href="{:url('Group/group_list')}" class="n_tab_list">商品列表</a>
            <a href="{:url('Group/group_add')}" class="n_tab_add">添加商品</a>
            <div class="cl"></div>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <form class="Huiform" method="post" action="{:url('Group/group_list')}" target="_self">
                <div class="text-c"> 商品名称：
                    <input type="text" class="input-text" value="{$group_name}" style="width:250px" placeholder="输入商品名称"  name="group_name">
                    <button type="submit" class="btn btn-search radius"  name=""><i class="Hui-iconfont">&#xe665;</i> 搜商品</button>
                </div>
            </form>
        </div>
        <table class="table table-border table-bordered table-hover table-bg">
            <thead>
            <tr class="text-c">
                <th>商品名称</th>
                <th>商品主图</th>
                <th>商品分类</th>
                <th>单买价</th>
                <th>拼团价</th>
                <th>起团人数</th>
                <th>组团显示</th>
                <th>库存</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="list" id="vo" key='k'}
            <tr>
                <td>{$vo['name']|subtext=10}</td>
                <td><img src="{:get_img_src($vo['img'])}" style="width: 50px;height: 50px;"></td>
                <td>{:get_pt_cname($vo['cid'])}</td>
                <td>￥{$vo['price']}</td>
                <td>￥{$vo['gprice']}</td>
                <td>{$vo['groupNum']}</td>
                <td>{$vo['limitTime']}小时</td>
                <td>{$vo['stock']}</td>
                <td>
                    {if $vo['isShow']==1}
                    <a href="javascript:;" onclick="bargain_status('{$vo.id}','off')"><span class="label label-success radius">正常</span></a>
                    {else}
                    <a href="javascript:;" onclick="bargain_status('{$vo.id}','on')"><span class="label label-danger radius">下架</span></a>
                    {/if}
                </td>
                <td>
                    <a href="__CONF_SITE__admin/group/group_edit&id={$vo.id}"><input class="btn btn-primary size-S radius" type="button" value="修改"></a>
                    <a><input class="btn btn-primary size-S radius" type="button" value="复制链接" onclick="copy_now('wxpath{$k}')" id="wxpath{$k}" data-clipboard-text="yb_shop/pages/pintuan/pages/goods/detail?gid={$vo.id}"></a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </article>
    <div class="n_page_no">
        {$list->render()}
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    /*
     参数解释：
     title	标题
     url		请求的url
     id		需要操作的数据id
     w		弹出层宽度（缺省调默认值）
     h		弹出层高度（缺省调默认值）
     */
    /*活动-状态*/
    function bargain_status(id,key){
        var msg='';
        if(key=='off'){
            msg='确定要下架吗？';
        }else {
            msg='确定要上架吗？';
        }
        layer.confirm(msg,function(){
            //此处请求后台程序
            //后台处理
            $.ajax({
                type : "post",
                url : "{:url('group/group_status')}",
                data : {
                    "id" : id,
                    "key":key
                },
                success : function(data) {
                    if (data['code'] > 0) {
                        layer.msg('操作成功',{icon:1,time:1000},function () {
                            window.location.reload();
                        });
                    }else{
                        layer.msg(data['message'], {icon: 2, time: 1000});
                    }
                }
            })
        });
    }
    /*活动-编辑*/
    function bargain_edit(title,url,w,h){
        layer_show(title,url,w,h);
    }
    function copy_now(id) {
        id='#'+id;
        var check=$(id).attr('data-clipboard-text');
        if(check.length<=0){
            layer.msg("链接信息有误", {icon: 2, time: 1000});
            return false;
        }
        var clipboard=new Clipboard(id);
        clipboard.on('success',function(e){
            layer.msg("链接复制成功", {icon: 1, time: 500});
        });
        clipboard.on('error', function(e) {
            layer.msg("链接信息有误", {icon: 2, time: 1000});
        });
    }
</script>
{/block}